home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Camelot
/
Camelot 134 (1991-10)(Swedish User Group of Amiga)(SE)(PD)[WB].zip
/
Camelot 134 (1991-10)(Swedish User Group of Amiga)(SE)(PD)[WB].adf
/
gr
/
gr.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-01
|
3KB
|
87 lines
/* This program opens a custom screen and window with menus */
/* The Project menu item "Quit" is the only item on that menu implemented */
/* The Misc menu items all work and demonstrate rudimentary drawing */
/* and color map calls */
#include "intuition.h"
int quit; /* global flag to quit program */
project(long item,long subitem)
{
switch(item) {
case 4: quit=1;break;
default: puts("Not implemented");
}
}
misc(long item,long subitem)
{
long y,x1,y1,x2,y2,i;
extern struct RastPort *RastPort;
extern struct Window *Window;
extern struct Screen *Screen;
switch(item) {
case 0:
/* get the coordinates inside the borders */
x1 = Window->LeftEdge + Window->BorderLeft - 1;
x2 = Window->Width - Window->BorderRight + 1;
y1 = Window->TopEdge + Window->BorderTop -1;
y2 = Window->Height - Window->BorderBottom;
for(y=y1;y<=y2;y++) { /* Draw color map */
SetAPen(RastPort,(y-y1)/24);
Move(RastPort,x1,y);
Draw(RastPort,x2,y);
}
break;
case 1: /* Setup an RGB colormap */
SetRGB4(&Screen->ViewPort,0,0,0,0);
SetRGB4(&Screen->ViewPort,1,0,0,7);
SetRGB4(&Screen->ViewPort,2,0,0,11);
SetRGB4(&Screen->ViewPort,3,0,0,15);
SetRGB4(&Screen->ViewPort,4,0,7,0);
SetRGB4(&Screen->ViewPort,5,0,11,0);
SetRGB4(&Screen->ViewPort,6,0,15,0);
SetRGB4(&Screen->ViewPort,7,0,7,7);
SetRGB4(&Screen->ViewPort,8,0,11,11);
SetRGB4(&Screen->ViewPort,9,0,15,15);
SetRGB4(&Screen->ViewPort,10,7,7,0);
SetRGB4(&Screen->ViewPort,10,11,11,0);
SetRGB4(&Screen->ViewPort,12,15,15,0);
SetRGB4(&Screen->ViewPort,13,7,0,7);
SetRGB4(&Screen->ViewPort,14,11,0,11);
SetRGB4(&Screen->ViewPort,15,15,0,15);
break;
case 2: /* Setup a Grey Level colormap */
for(i=0;i<16;i++) SetRGB4(&Screen->ViewPort,i,i,i,i);
break;
default: puts("Not implemented");
}
}
main()
{
long choice,menu,item,subitem;
init_libs(); /* open the libraries, screen, and window */
init_screen();
init_window();
while(choice=handle_user(&menu,&item,&subitem) && quit==0) {
switch(choice) {
case 1: /* Menu pick */
/* subitem will equal 31 if no subitem was attached to menu */
switch(menu) {
case 0: project(item,subitem);break;
case 1: misc(item,subitem);break;
}
break;
default:
printf("choice = %ld\n",choice);
break;
}
}
close_all();
}